<div id="dialog-form-supplier" title="商家管理"></div>
<div id="map-dialog" class="ui-widget"></div>
<div id="supplier-contain" class="ui-widget">
<div>
	<span>
		类别:
		<select id="categoryType" style="display: inline;" class="ui-widget-content ui-corner-all">
			<?php 
				echo '<option value="0">请选择...</option>';
				foreach ($result_supplier_category as $subItem){
					echo '<option value="'.$subItem->id.'"';
					if(!empty($result_category_type)){
						if ($result_category_type==$subItem->id){
							echo ' selected = selected';
						}
					}
					echo '>'.$subItem->name.'</option>';
				}
			?>
		</select>
		名称:
	<input type="text" name="searchText" id="searchText" style="display: inline;float: none;" class="ui-widget-content ui-corner-all" value="<?php if (!empty($result_search_text)) echo $result_search_text?>"/>
	<button id="query-supplier">查询</button>
	</span>
</div>
<table id="supplier" class="ui-widget ui-widget-content">
	<thead>
		<tr class="ui-widget-header ">
			<th><input type="checkbox" onclick="changeSelectAll(this,'checkKey');"></th>
			<th>类别</th>
			<th>名称</th>
			<th>地址</th>
			<th>路段</th>
			<th>电话</th>
			<th>起送金额</th>
			<th>外卖范围</th>
			<th>排序</th>
			<th>营业时间</th>
			<th>菜系</th>
			<th>状态</th>
		</tr>
	</thead>
	<tbody>
	<?php
	foreach ($result_supplier as $item){
		echo '<tr><td><input type="checkbox" class="checkKey" key="'.$item->id.'"/></td>';
		echo '<td>';
		foreach ($result_supplier_category as $subItem){
			if ($subItem->id == $item->sup_cate_id){
				echo $subItem->name;
			}
		}
		echo '</td>';
		echo '<td><a style="color:blue" title="查看详细" href="javascript:void(0)" onclick="showDetail('.$item->id.')">['.$item->id.']-'.$item->name.'</a>';
		echo '</td>';
		echo '<td>'.$item->address.'&nbsp;<a style="color:blue" title="地图" href="javascript:void(0)" onclick="openMapDialog('.$item->id.')">'.'设置坐标'.'</a>';
		if (!empty($item->map_address)){
			echo '&nbsp;&nbsp;<span style="color:green">[已设置]</span>';	
		}else{
			echo '&nbsp;&nbsp;<span style="color:red">[未设置]</span>';	
		}
		echo '</td>';
		echo '<td>'.$item->road.'</td>';
		echo '<td>'.$item->phone.'</td>';
		echo '<td>'.$item->leastprice.'</td>';
		echo '<td>'.$item->leastdistance.'</td>';
		echo '<td>'.$item->sort.'</td>';
		echo '<td>'.$item->displayOpen().'</td>';
		$dish_category = ORM::factory("dishCategory");
		$result_dish_category = $dish_category->where("supplierid","=",$item->id)->and_where("status","=","A")->find_all();
		echo '<td><select id="dish_category_id" name="dish_category_id" onchange="changeDishCate(this)" class="text ui-widget-content ui-corner-all">';
		echo '<option value="0">请选择...</option>';
		foreach ($result_dish_category as $subItem){
			echo '<option value='.$subItem->id.'>'.$subItem->name.'</option>';
		}
		echo '</select>&nbsp;<a style="color:blue" title="管理菜系" href="javascript:void(0)" onclick="showSupplierDishCate('.$item->id.')">管理</a></td>';
		echo '<td width="8%"><span id="status-'.$item->id.'" style="color:red">'.$item->displayStatus().'</span>';
		if ($item->displayStatus() == "正在审核" || $item->displayStatus() == "审核失败"){
			echo '<br/><a style="color:blue" supplierid="'.$item->id.'" href="javascript:void(0)" onclick="approveSupplier(this)">通过</a>';
			if ($item->displayStatus() == "正在审核"){
				echo '&nbsp;<a id="unApprove-'.$item->id.'" style="color:blue" supplierid="'.$item->id.'" href="javascript:void(0)" onclick="unApproveSupplier(this)">失败</a>';
			}
		}
		echo '</td>';
	}?>
	</tbody>
</table>
<div class="page clear"><?php echo $page_links;?></div>
<button id="create-supplier">添加商家</button>
<button id="edit-supplier">修改商家</button>
<button id="delete-supplier">删除选中商家</button>
<button id="create-dish-category">增加菜系</button>
<button id="create-dish-bunddle">增加套餐</button>
<input type="hidden" id="currentPage" value="<?php echo $current_page?>"/>
</div>
